//Time class is used to store time data

class Time
{
  int [] years;
  int [] months;
  int yearsMin;
  int yearsMax;
  int monthsMin;
  int monthsMax;
  int interval;
  Time(int [] yr, int [] mon)
  {
    years = yr;
    months= mon;
    /*for (int i = 0 ;i<months.length;i++)
    {
      println("months[i] is "+months[i]);
    }*/
    setYearsMin();
    setYearsMax();
    interval = 12;
  }
  void setYearsMin()
  {
    yearsMin = 10000;
    for( int i =1; i<years.length;i++)
    {
      if( years[i] <yearsMin)
      yearsMin = years[i];
    }
  }
  int getYearsMin()
  { return yearsMin;}
  void setYearsMax()
  {
    yearsMax = -1;
    for( int i =1; i<years.length;i++)
    {
      if( years[i] >yearsMax)
      yearsMax = years[i];
    }
  }
  int getYearsMax()
  {
    return yearsMax;
  }
  int getMonth(int row)
  {
    return months[row];
  }
  int getRowTime(int row)
  {
    if(row< years.length){
    if( years[row]!=0 && months[row]!=0 )
        return int( (years[row]-getYearsMin())*12 + months[row]);
        else return 0;
    }
    else
        return 0;
  }
  int getTimeBegin()
  {
    int m=10000;
    for( int i = 0 ;i< years.length;i++)
    {
      if( years[i]!=0 && months[i]!=0)
      if( (years[i]-yearsMin)*12 + months[i]< m )
        m= (years[i]-yearsMin)*12 + months[i];
    }
    return m;
    
  }
  int getTimeEnd()
  {
    int m=-1;
    for( int i = 0 ;i< years.length;i++)
    {
      if( years[i]!=0 && months[i]!=0)
      if( (years[i]-yearsMin)*12+ months[i]> m )
      m= (years[i]-yearsMin)*12+ months[i];
    }
    return m;
  }
 
  int getTimeScale()
  {
    int yearsDifference = getYearsMax()-getYearsMin();
    return (yearsDifference+1) *12;
  }
  
  int getInterval()
  {
    return interval;
  }

String getYearString(int row)
{
  return Integer.toString(years[row]);
}
String getTimeString(int row)
{
  String temp ="";

  switch (months[row])
  {
    case 1:
    temp+="January";
    break;
    case 2:
        temp+="Febrary";
    break;
    case 3:
        temp+="Marth";
    break;
    case 4:
        temp+="April";
    break;
    case 5:
        temp+="May";
    break;
    case 6:
        temp+="June";
    break;
    case 7:
        temp+="July";
    break;
    case 8:
        temp+="August";
    break;
    case 9:
        temp+="September";
    break;
    case 10:
        temp+="October";
    break;
    case 11:
        temp+="November";
    break;
    case 12:
        temp+="December";
    break;
  }
  temp +=" , ";
  temp +=Integer.toString(years[row]);  
  temp +="\n";
  return temp;
}
  /*void setMonthsMin(int mon)
  {
    int min = 10000;
    for( int i =0; i<months.length;i++)
    {
      if( months[i] <min)
      min = months[i];
    }
  }
  void setMonthsMax(int mon)
  {
    int max = -1;
    for( int i =0; i<months.length;i++)
    {
      if( months[i] >max)
      max = months[i];
    }
  }*/
  
  
 
}

